#include "visit.h"

/*!
 *@brief 访问变量定义
 *@param node AST节点指针
 *@param s 符号表指针
 *@param bb 基本块指针
 *@return pair<string, variant<int, float> > 

 * pair.first -> 变量标识符 string

 * pair.second -> 变量初始值 variant<int, float>
 *@note 使用
    if(auto pval = std::get_if<int>(&v))
        int value = *pval;
    else 
        float value = *pval;
 */
pair<string, variant<int, float, string> > visit_varDef(ASTNode* node, SymbolTable* s, Module* m, BasicBlock* bb){
    ASTNode* ident = node -> children[0];
    ASTNode* argvardef = node -> children[1];

    string res_ident = visit_Ident(ident, s, bb);
    variant<int, float, string> res_argvardef = visit_argVarDef(argvardef, s, m, bb);

    return make_pair(res_ident, res_argvardef);
}